(function(S) {
	S.declare('Modal', S.Widget, {
		className : 'simple-modal',
		node : null,
		init:function(){
			this.render();
		},
		renderUI:function(){
			this.setPosition();
		},
		bindUI:function(){
			$(window).bind('resize:modal', $.proxy(this.setPosition, this));
			$(window).resize(function() {
				$(this).trigger('resize:modal');
			});
		},
		setPosition : function() {
			var nodeOffset = this.node.offset(), nodeOuterSize = S.getSize(this.node, true);
			this.container.css(nodeOffset).css({
				width : nodeOuterSize.w,
				height : nodeOuterSize.h
			});
		},
		destroy : function() {
			this.inherit(arguments);
			$(window).unbind('resize:modal');
		}
	});
	S.bridgeTojQuery('modal',S.Modal);
})(Simple);
